package com.acxiom.bsh.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.acxiom.bsh.cache.TokenCache;
import com.acxiom.bsh.logger.LoggerManager;
import com.acxiom.bsh.pojo.ApiToken;
import com.acxiom.bsh.service.ApiTokenService;
import com.acxiom.bsh.service.ApiTokenTask;

@Service
public class ApiTokenTaskImpl implements ApiTokenTask{

	@Autowired
	ApiTokenService apiTokenService;
	
	@Override
	public void init() {
		LoggerManager.getCommonLogger().info("Start to load api token");
		ApiToken apiToken = apiTokenService.getToken();
		if (apiToken != null) {
			TokenCache.setApiToken(apiToken);
			LoggerManager.getCommonLogger().info("load api token successfully");
		} else {
			LoggerManager.getCommonLogger().info("failed to load api token");
		}
		LoggerManager.getCommonLogger().info("end of load api token");
	}

}
